package com.atguigu.lease.web.app.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.atguigu.lease.model.entity.PaymentType;
import com.atguigu.lease.model.entity.RoomPaymentType;
import com.atguigu.lease.web.app.mapper.PaymentTypeMapper;
import com.atguigu.lease.web.app.service.PaymentTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @author liubo
* @description 针对表【payment_type(支付方式表)】的数据库操作Service实现
* @createDate 2023-07-26 11:12:39
*/
@Service
public class PaymentTypeServiceImpl extends ServiceImpl<PaymentTypeMapper, PaymentType>
    implements PaymentTypeService{

    @Override
    public List<PaymentType> getlist(Long id) {
        List<RoomPaymentType> roomPaymentTypes = Db.lambdaQuery(RoomPaymentType.class)
                .eq(RoomPaymentType::getRoomId, id).list();
        if(CollUtil.isNotEmpty(roomPaymentTypes))
        {
            List<PaymentType> paymentTypes = lambdaQuery()
                    .in(PaymentType::getId, roomPaymentTypes)
                    .list();
            return paymentTypes;
        }
        else throw new RuntimeException();
    }
}




